package com.burstly.lib.component.networkcomponent.burstly.html.mraid;

import android.app.Activity;
import android.content.Context;
import android.graphics.Color;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.FrameLayout;
import android.widget.ViewFlipper;
import com.burstly.lib.component.networkcomponent.IActivityLifeCycleAware;
import com.burstly.lib.component.networkcomponent.burstly.OverlayContainer;
import com.burstly.lib.component.networkcomponent.burstly.html.CloseableContainer;
import com.burstly.lib.component.networkcomponent.burstly.html.ICloseControl;

class MraidOverlay<T extends MraidView,  extends IActivityLifeCycleAware> extends OverlayContainer<T>
  implements View.OnClickListener
{
  private static int sGlobalMockViewIdCounter = 14003;
  int mChildIndex = -1;
  private ViewGroup.LayoutParams mLayoutParams;
  private int mLocalMockViewId;
  private ICloseControl mOriginalCloseButtonControl;

  MraidOverlay(T paramT, ViewGroup paramViewGroup)
  {
    super(paramViewGroup, paramT);
    int i = 1 + sGlobalMockViewIdCounter;
    sGlobalMockViewIdCounter = i;
    this.mLocalMockViewId = i;
  }

  private void placeStubView(ViewGroup paramViewGroup)
  {
    FrameLayout localFrameLayout = new FrameLayout(getContext());
    localFrameLayout.setId(this.mLocalMockViewId);
    localFrameLayout.setBackgroundColor(-16777216);
    localFrameLayout.setLayoutParams(this.mLayoutParams);
    paramViewGroup.addView(localFrameLayout, this.mChildIndex);
  }

  protected CloseableContainer<?> addChildToLayout(ViewGroup paramViewGroup, T paramT)
  {
    CloseableContainer localCloseableContainer = new CloseableContainer(getContext());
    localCloseableContainer.putIntoContainer(paramT);
    localCloseableContainer.setCloseClickListener(this);
    localCloseableContainer.setShowCloseIndicator(false);
    paramT.setCloseButtonControl(localCloseableContainer);
    paramT.requestFocus(130);
    paramViewGroup.addView(localCloseableContainer);
    return localCloseableContainer;
  }

  protected ViewGroup createContainerLayout()
  {
    FrameLayout local1 = new FrameLayout(getContext())
    {
      public boolean onTouchEvent(MotionEvent paramAnonymousMotionEvent)
      {
        return true;
      }
    };
    local1.setBackgroundColor(Color.argb(200, 255, 255, 255));
    return local1;
  }

  public void hideOverlayed()
  {
    if (isShowing())
    {
      super.hideOverlayed();
      MraidView localMraidView = (MraidView)getChildView();
      ViewGroup localViewGroup1 = (ViewGroup)localMraidView.getParent();
      if (localViewGroup1 != null)
        localViewGroup1.removeView(localMraidView);
      View localView = ((Activity)getContext()).findViewById(this.mLocalMockViewId);
      if (localView != null)
      {
        ViewGroup localViewGroup2 = (ViewGroup)localView.getParent();
        localViewGroup2.removeView(localView);
        localViewGroup2.addView(localMraidView, this.mChildIndex, this.mLayoutParams);
        if ((localViewGroup2 instanceof ViewFlipper))
          ((ViewFlipper)localViewGroup2).setDisplayedChild(this.mChildIndex);
      }
      if (this.mOriginalCloseButtonControl != null)
        localMraidView.setCloseButtonControl(this.mOriginalCloseButtonControl);
    }
  }

  public void onClick(View paramView)
  {
    ((MraidView)getChildView()).close();
  }

  public void showOverlayed()
  {
    MraidView localMraidView;
    ViewGroup localViewGroup;
    int i;
    if (!isShowing())
    {
      localMraidView = (MraidView)getChildView();
      this.mLayoutParams = localMraidView.getLayoutParams();
      this.mOriginalCloseButtonControl = localMraidView.getCloseButtonControl();
      localViewGroup = (ViewGroup)localMraidView.getParent();
      if (localViewGroup != null)
        i = localViewGroup.getChildCount();
    }
    for (int j = 0; ; j++)
      if (j < i)
      {
        if (localViewGroup.getChildAt(j) == localMraidView)
          this.mChildIndex = j;
      }
      else
      {
        localViewGroup.removeView(localMraidView);
        placeStubView(localViewGroup);
        super.showOverlayed();
        return;
      }
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.burstly.lib.component.networkcomponent.burstly.html.mraid.MraidOverlay
 * JD-Core Version:    0.6.2
 */